package com.may.copy.old;

import java.io.DataInputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @program: com.may.netty
 * @description: 传统 io 服务器端
 * @author: Bobby.Ma
 * @create: 2020-09-20 10:19
 **/
public class OldIOServer {
    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket(9999);

        while (true){
            System.out.println("服务器启动，等待客户端连接...");
            Socket socket = serverSocket.accept();
            System.out.println("客户端已连接");
            DataInputStream dataInputStream = new DataInputStream(socket.getInputStream());

            byte[] bytes = new byte[4096];
            while (true){
                int read = dataInputStream.read(bytes, 0, bytes.length);
                if (read == -1){
                    break;
                }
            }
        }
    }
}
